package ar.edu.ufasta.presupuestos.servicios.web.netpacks;

import java.util.StringTokenizer;

import ar.edu.ufasta.presupuestos.servicios.web.Constantes;

public class InfoClienteRequest extends RequestPack {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8956027288940644106L;
	private int idCliente;

	
	@Override
	public void codificarTrama() {
		trama = "";
		trama = trama + protocol + ";";
		trama = trama + systemCode + ";";
		trama = trama + operationCode + ";";
		trama = trama + idCliente + ";";
		int checksum = trama.length() + 1;
		trama = trama + Integer.toString(checksum) + ";";
		trama = trama + "\n";
	}

	@Override
	public void decodificarTrama() {
		StringTokenizer st = new StringTokenizer(trama,";");
		st.countTokens();
		try {
			protocol = Integer.valueOf(st.nextToken());
			systemCode = Integer.valueOf(st.nextToken());
			operationCode = Integer.valueOf(st.nextToken());
			idCliente = Integer.valueOf(st.nextToken());
		} catch (Exception e) {
			protocol = Constantes.PROTOCOL_100;
			systemCode = Constantes.SYSTEM_CODE;
			operationCode = 999;
		}	
	}

	/**
	 * @return the idCliente
	 */
	public int getIdCliente() {
		return idCliente;
	}

	/**
	 * @param idCliente the idCliente to set
	 */
	public void setIdCliente(int idCliente) {
		this.idCliente = idCliente;
	}

}
